Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum





Exporting to MS Access
~Dean Chulumar 01/27/2004 03:41 PM
Applications Development All Releases All Platforms


I have been looking at the MS Access ODBC export posted in Sandbox, but can not get the code to work. Has anyone got any ideas where I am going wrong. I have added a ODBC entry and tested it using other software. But I cannot get a connection using this code:

Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Set qry.Connection = con
Set result.Query = qry
Set session = New NotesSession
Set db = session.CurrentDatabase
Set view = db.GetView("addtoaccess")
'connects to the database
con.ConnectTo("stockcode")

'queries the table Contacts.
qry.SQL = "SELECT * FROM STOCKCODES"

'result is what temp stores the value and is pointing to the execute command.
result.Execute

Set doc = view.GetFirstDocument
While Not(doc Is Nothing)

'If the value is empty then get the next document else get the document that you are pointing at.
If result.IsValueNull(uidoc.CurrentField) Then
Set doc = view.GetNextDocument(doc)

'update the value and adds it to the row
result.AddRow
Call result.SetValue("STOCKCODE",doc.STOCKCODE(0))
Call result.SetValue("DESCRIPTION",doc.DESCRIPTION(0))
Call result.SetValue("CAT",doc.CAT(0))
Call result.SetValue("DATE_ENTER",doc.DATE_ENTER(0))
Call result.SetValue("OLDNO",doc.OLDNO(0))
Call result.SetValue("SIZE",doc.SIZE(0))
result.UpdateRow
Set doc = view.GetNextDocument(doc)
Else
result.AddRow
Call result.SetValue("STOCKCODE",doc.STOCKCODE(0))
Call result.SetValue("DESCRIPTION",doc.DESCRIPTION(0))
Call result.SetValue("CAT",doc.CAT(0))
Call result.SetValue("DATE_ENTER",doc.DATE_ENTER(0))
Call result.SetValue("OLDNO",doc.OLDNO(0))
Call result.SetValue("SIZE",doc.SIZE(0))
result.UpdateRow
Set doc = view.GetNextDocument(doc)
End If
Wend
result.Close(DB_CLOSE)
con.Disconnect

Go back